<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/3/2
  Time: 17:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--导入taglib--%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>用户列表</title>
    <style>
        #div_foot{
            margin-left: 420px;
        }
    </style>
    <!--导入boostrap的css文件-->
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet" >
    <!--导入jquery文件-->
    <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
    <!--导入boostrap的js库-->
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>

</head>
<body>
    <table  width="100%" class="table table-responsive table-bordered table-hover table-striped">
        <tr>
            <th>
                <input type="checkbox" />
            </th>
            <th>uid</th>
            <th>姓名</th>
            <th>密码</th>
            <th>昵称</th>
            <th>邮箱</th>
            <th>birthday</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${pb.list}" var="u">
            <tr>
                <td>
                    <input type="checkbox" />
                </td>
                <td>${u.uid}</td>
                <td>${u.username}</td>
                <td>${u.password}</td>
                <td>${u.name}</td>
                <td>${u.email}</td>
                <td>${u.birthday}</td>
                <td>
                    <a class="btn btn-primary" href="${pageContext.request.contextPath}/admin?methodName=findUserByUid&uid=${u.uid}">修改</a>
                    <a href="javascript:void(0)" id="del" onclick="delUser('${u.uid}')" class="btn btn-danger">删除</a>
                </td>
            </tr>

        </c:forEach>

    </table>
        <span style="float: right;margin-right: 20px;font-size: 25px">共有${pb.totalPage}页</span>
        <span style="float: right;margin-right: 20px;font-size: 25px">共有${pb.totalCount}记录数</span>





<%--分页条--%>
    <div id="div_foot">
        <nav aria-label="Page navigation">
            <ul class="pagination">
                <%--
                    判断是否是第一页
                    判断是第一页
                --%>
                <c:if test="${pb.currentPage==1}">
                    <%--页面的状态：禁用状态--%>
                    <li class="disabled">
                        <a href="javascript:void(0)" aria-label="Previous">
                            <span aria-hidden="true">&laquo;</span>
                        </a>
                    </li>
                </c:if>

                 <%--判断如果不是第一页--%>
                    <c:if test="${pb.currentPage!=1}">

                        <li>
                            <a href="${pageContext.request.contextPath}/admin?methodName=findUserByPage&currentPage=${pb.currentPage-1}&pageSize=2" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>


                <%--遍历页码数--%>
                <c:forEach begin="1" end="${pb.totalPage}" step="1" var="n">
                    <%--判断是否是当前页--%>
                    <c:if test="${pb.currentPage==n}">
                        <%--
                            bootstrap的分页组件的属性active:激活状态
                        --%>
                        <li class="active"><a href="javascript:void(0)">${n}</a></li>
                    </c:if>
                    <%--判断如果不是当前也,翻页查询--%>
                    <c:if test="${pb.currentPage!=n}">
                        <li><a href="${pageContext.request.contextPath}/admin?methodName=findUserByPage&currentPage=${n}&pageSize=2">${n}</a></li>
                    </c:if>



                </c:forEach>

           <%--     <li><a href="#">2</a></li>
                <li><a href="#">3</a></li>
                <li><a href="#">4</a></li>
                <li><a href="#">5</a></li>--%>

                    <%--判断是否是最后一页
                            是最后一页
                   --%>
               <c:if test="${pb.currentPage==pb.totalPage}">

                    <li class="disabled"> <%--禁用状态--%>
                        <a href="javascript:void(0)" aria-label="Next">
                            <span aria-hidden="true">&raquo;</span>
                        </a>
                    </li>
                </c:if>
                <%--
                    如果不是最后一页
                --%>
                    <c:if test="${pb.currentPage!=pb.totalPage}">

                        <li>
                            <a href="${pageContext.request.contextPath}/admin?methodName=findUserByPage&currentPage=${pb.currentPage+1}&pageSize=2" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>
            </ul>
        </nav>
    </div>

</body>
<script>
        //编写一个函数 原生js
        function  delUser(uid){
               var flag =  window.confirm("您确认删除吗?") ;
               //点击确认按钮,flag就是true ,点击取消按钮,false
               if(flag){
                    //改变url地址
                  // alert(uid) ;
                   window.location.href="${pageContext.request.contextPath}/admin?methodName=delUser&uid="+uid;
                }

        }
</script>
</html>
